import unittest

import app
from api.login import LoginApi
from utils import common_assert


class TestLogin(unittest.TestCase):

    def setUp(self) -> None:
        self.login_api = LoginApi()

    def test01_case01(self):
        response = self.login_api.login({"mobile": "13800000002", "password": "123456"})
        print(response.json())
        common_assert(self,response,200,True,10000,"操作成功")

        app.TOKEN = "Bearer " + response.json().get("data")
        print(app.TOKEN)
        app.headers_data["Authorization"] = app.TOKEN
        print(app.headers_data["Authorization"])

    def test01_case02(self):
        response = self.login_api.login({"mobile": "", "password": "123456"})
        print(response.json())
        common_assert(self, response, 200, False, 20001, "用户名或密码错误")

